//
//  main.m
//  OC03_属性
//
//  Created by dllo on 15/12/2.
//  Copyright © 2015年 dllo. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Person.h"
#import "Phone.h"
#import "Fraction.h"

int main(int argc, const char * argv[]) {
    @autoreleasepool {

#pragma mark - 知识点1 属性
        
        /** 属性的三个作用:
         * 1. 声明了一个实例变量, 名字为 _属性名
         * 2. 声明和实现 setter 方法
         * 3. 声明和实现 getter 方法
         *
         * 详见Person类
         */
        
#pragma mark - 知识点2 属性的特性(3个特性)
        
        /** 
         * 属性的三个特性
         * 1. 可读性
         * 2. 原子性
         * 3. 语义特性
         *
         * 详见Person类
         */

#pragma mark - 知识点3 点语法
        
        /** !!!!注意!!!!
         * 点语法 只对属性的访问起作用
         * 其他方法, 还是[ ] 消息语法格式
         */
        
        Phone *phone = [Phone phoneWithType:@"SAMSUNG" colour:@"黑色" size:4.5];
        NSLog(@"colour:%@", phone.colour);
        
        
        Phone *phone1 = [[Phone alloc] init];
        phone1.type = @"APPLE";
        phone1.colour = @"white";
        phone1.size = 4.5;
        
        NSLog(@"type:%@, colour:%@, size:%.2f", phone1.type, phone1.colour, phone1.size);
        
        
#pragma mark - 综合练习
        
        Fraction *fra1 = [[Fraction alloc] initWithNumerator:1 denominator:2];
        Fraction *fra2 = [[Fraction alloc] initWithNumerator:2 denominator:5];
        
        Fraction *sum = [fra1 addOperationWithFraction:fra2];
        NSLog(@"numerator:%ld denominator:%ld",sum.numerator, sum.denominator );
        
        Fraction *subtraction = [fra1 subtractionOperationWithFraction:fra2];
        NSLog(@"numerator:%ld denominator:%ld", subtraction.numerator, subtraction.denominator);
       
        Fraction *multiplication = [fra1 multiplicationOperationWithFraction:fra2];
        NSLog(@"numerator:%ld denominator:%ld", multiplication.numerator, multiplication.denominator);
        
        Fraction *division = [fra1 divisionOperationWithFraction:fra2];
        NSLog(@"numerator:%ld denominator:%ld", division.numerator, division.denominator);
        
        
        
        
        
        
        
        
        
        
        
        
        
        
    }
    return 0;
}
